function last() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    // console.log(currentdate);
    $.ajax({
        url: '/admin/comments',
        type: 'get',
        success: function (res) {
            let src = '';
            for (let i = 0; i < res.data.length; i++) {
                src += `<tr>
            <td>${res.data[i].id}</td>
            <td>${res.data[i].uname}</td>
            <td>${res.data[i].content}</td>
            <td>${currentdate}</td>
            <td><a href="#" class="layui-btn layui-btn-danger abc" data-id=${res.data[i].id}>删除</a></td>
          </tr>`
            };
            $('tbody').html(src);
        }

    })
}
last()
$('tbody').on('click', '.abc', function (e) {
    let id = $(this).attr('data-id');
    // console.log(id);
    layer.confirm('你确定删除？', { icon: 3, title: '提示' }, function (index) {
        $.ajax({
            url: '/admin/comments/' + id,
            type: 'DELETE',
            success: function (res) {
                if (res.status == 0) {
                    layer.close(index);
                    last()
                }
            }
        })
    });
})